/*
 * MAtoms.h
 *
 *  Created on: Aug 7, 2013
 *      Author: marchi
 */

#ifndef MATOMS_H_
#define MATOMS_H_


#include <string>
#include <map>
#include <algorithm>
#include <cmath>

#include "FAtoms.h"
#include "TopolMic.h"
#include "MyUtilClass.h"
#include "Gyration.h"
#include "Percolation.h"

using namespace std;
using namespace Topol_NS;
using namespace MATRIX;

class MAtoms: public FAtoms {
protected:
	map<string,vector<Dvect> > ResXYZ;
	static int calls;
	static vector<string> * ResList0;
	static vector<int> * ResIndx0;
	vector<Gyration> Rg_i,Rg_stat;
	int Rg_count;
	vector<double> mass;
	static map<string,double> MMass;
	static string MIons;
	vector<vector<int> > MyRes,SelRes;
	vector<PDBdata> PDB;
	virtual void cPrint(ostream &);
	virtual void fPrint(Fstream &);
	Percolation * Perco;
public:
	MAtoms();
	MAtoms(Atoms & x): FAtoms(x),Rg_count(0), Perco(NULL) {};
	void Reconstruct(const string &, TopolMic &);
	void Reconstruct();
	void InitSelection(vector<string> &, TopolMic &);
	void Gyro();
	Matrix InertiaRot();
	Dvect CM();
	Matrix InertiaRotCenter();
	Dvect CMCenter();

	virtual void initLists(TopolPDB &,vector<string> &);
	vector<Gyration> & getRg_i(){return Rg_i;};
//	Gyration getRg_stat(){return Rg_stat/Rg_count;};
	vector<double> getM(){return mass;}
	bool testMass(){return !mass.empty();}
	vector<int> & getIndx(){return *ResIndx0;}
	void Percolate(vector<vector<int> > &);
	Percolation & Percolate();
	vector<Comp> & getComp(){return Perco->getClustComp();}
	virtual void gDipole(){};
	virtual void dPrint(ostream & fout){};
	static vector<string> & gResList(){return *ResList0;}
	static string gTotResList();
	friend ostream & operator<<(ostream & , MAtoms &);
	friend Fstream & operator<<(Fstream & fout, MAtoms &);
	virtual ~MAtoms();
};

#endif /* MATOMS_H_ */
